<!DOCTYPE html>
<html>
<head>
    <title>内部资料学习系统</title>
    <meta name="keywords" content=""/>
    <meta name="description" content="">
    <include file="public@head"/>
</head>
<style>
	select{
		text-align: center;
		text-align-last: center;
		outline: none;
	}
	select option{text-align: center;}
</style>
<body class="body-white">


<div class="container tc-main">
    <div class="row">
        <div class="col-md-4 col-md-offset-4">
            <h2 class="text-center">内部资料学习系统注册</h2>
            <notempty name="theme_vars.enable_mobile">
                <ul class="nav nav-tabs nav-justified" id="myTab" style="margin-bottom: 15px;">
                    <li class="active"><a href="#email" data-toggle="tab">邮箱注册</a></li>
                </ul>
            </notempty>

                <div class="tab-pane">
                    <form>
                        <div class="form-group">
                            <input type="text" id="username" placeholder="姓名" class="form-control">
                        </div>
                        <div class="form-group">
                            <input type="text" id="email" placeholder="QQ邮箱(ps:邮箱即是账号)" class="form-control">
                        </div>
                        <div class="form-group">
                            <input type="password" id="pass" placeholder="设置密码(ps:最少6位)" class="form-control">
                        </div>
                        <div class="form-group">
                            <input type="password" id="password" placeholder="确认密码" class="form-control">
                        </div>
                        <div class="form-group">
                            <input type="text" id="phone" placeholder="手机号" class="form-control">
                        </div>
                        <div class="form-group">
							<select class="select form-control" size="1" id="place">
								<option value="0" disabled="disabled" selected="selected">请选择职位</option>
								<option value="1">管理员</option>
								<option value="2">总经理</option>
								<option value="3">项目总监</option>
								<option value="4">员工</option>
							</select>
                        </div>
						<div class="form-group">
                            <input type="text" id="bankuai" placeholder="版块名(ps:版块名简称)" class="form-control">
                        </div>
						<div class="form-group">
                            <input type="text" id="project" placeholder="项目名(ps:项目名简称)" class="form-control">
                        </div>
                        <div class="form-group">
                            <button class="btn btn-primary btn-block" id="sub" type="button" data-wait="1500"
                                    style="margin-left: 0px;">确定注册
                            </button>
                        </div>

                        <div class="form-group" style="text-align: center;">
                            <p>
                                已有账号? <a href="{:cmf_url('portal/Index/login')}">点击此处登录</a>
                            </p>
                        </div>
                    </form>

                </div>

        </div>
    </div>

</div>
<!-- /container -->

<include file="public@scripts"/>
<script type="text/javascript">
    $('#sub').click(function(){
      bankuai_id = $('#bankuai').val(); //板块名
      project = $('#project').val(); //项目名
      username = $('#username').val(); //用户名
      email = $('#email').val(); //邮箱
      pass = $('#pass').val(); //密码
      password = $('#password').val(); //确认密码
      phone = $('#phone').val(); //手机号
      place = $('#place').val(); //职位
      //验证是否为空
      if(
        bankuai_id == null || bankuai_id == undefined || bankuai_id == "" ||
        project == null || project == undefined || project == "" ||
        username == null || username == undefined || username == "" ||
        email == null || email == undefined || email == "" ||
        pass == null || pass == undefined || pass == "" ||
        password == null || password == undefined || password == "" ||
        phone == null || phone == undefined || phone == "" ||
        place == null || place == undefined || place == ""
      ){
        alert("不能为空哦！");
        return false;
      }

      //验证密码
      if(pass != password){
          alert('密码不一致');return false;
      }
      if(pass.length<6){
          alert('至少6位数');return false;
      }
      //验证手机号
      var vali=/[1][0-9][0-9]{9}/;
        if(vali.test(phone) == false){
        alert("手机号格式错误");return false;
        }

              //验证邮箱
      var qq_email=/[1-9]\d{7,10}@qq\.com/;
        if(qq_email.test(email) == false){
        alert("QQ邮箱格式错误");return false;
        }
    
      $.ajax({
        type:"post",
        url:"{:url('portal/index/register')}",
        data:{
            'bankuai_id' : bankuai_id,'project' : project,'username' : username,
            'email' : email,'pass' : pass,'phone' : phone,'place' : place,
        },
        dataType:"json",
        success:function($msg){
            if($msg.status == 0){
                alert($msg.info);
            }else if($msg.status == 1){
                var msg = $msg.info;  
            if (confirm(msg)==false){  
                return false;
            }
                window.location.href="{:url('/')}";return false;
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {	
            alert('未知错误!!!');return false;
		}

      });
    });
   
</script> 
</body>
</html>
